package cn.ml.gaoJi.api;

import java.util.Random;

public class RandomDemo {
    public static void main(String[] args) {

        Random random = new Random();
        System.out.println("随机整数："+random.nextInt());
        Random random1 = new Random(56);
        Random random2 = new Random(56);//有种子(56)生成随机数一直一样，时间毫秒数当种子可以当种子，这样产生的就不会一样了
        System.out.println("有种子(56)生成随机数一直一样"+random1.nextInt()+"#####"+random2.nextInt());
        System.out.println("***************************************************");
        Random random3 = new Random();
        Random random4 = new Random();//无种子生成随机数不一定一样
        System.out.println("无种子生成随机数不一定一样"+random3.nextInt(10)+"#####"+random4.nextInt(10));
        System.out.println("10范围内的随机整数11111："+random.nextInt(10));
        System.out.println("10范围内的随机整数22222："+(int)(Math.random()*10));

    }
}
